﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<amk.ViewModels.CadastroIndexViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">Index</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Index</h2>

  <%= Html.ValidationSummary("Search was unsuccessful. Please correct the errors and try again.") %>

  <% using (Html.BeginForm("Index", "Cadastro", FormMethod.Post, new { id = "frmCadastro" })){ %>
  
    <fieldset title="Pesquisar Cadastro">
      <legend>Pesquisar Cadastro</legend>
      <div>
          <label for="DSC_NOME">Nome do Funcionário</label><br />
          <%: Html.TextBox("DSC_NOME", "", new { size = "60", maxlength = "250" })%>
          <%: Html.ValidationMessage("DSC_NOME", "*")%>
      </div>
      <div>
          <input type="submit" value="Pesquisar" class="btPesquisar" />
      </div>
    </fieldset>
  
  <% } %>

    <table id="tabelaResultado" summary="Registros encontrados">
      <caption> Registros encontrados</caption>
      <thead>
        <tr>
          <th>&nbsp;</th>
          <th>Nome Completo</th>
          <th>Data de cadastro</th>
          <th>Idade</th>
          <th>Celular</th>
          <th>Academia</th>
          <th>Graduação</th>
        </tr>
      </thead>

     <tfoot>
		  <tr>
			  <td id="paginacao" colspan="3">
         <%= Html.PageLinks((int)Model.paginaAtual, (int)Model.totalPaginas, i => Url.Action("Index", new { pagina = i }))%>
        </td>
			  <td id="totalResultado" colspan="7">Resultados encontrados:&nbsp;<%: Model.totalCadastro %></td>
		  </tr>
	  </tfoot>


      <tbody>

    <% 
      int cont = 0;
      foreach (var cadastro in Model.Cadastro) { %>
    
        <tr <%= cont++ % 2 == 1 ? "class='branco'" : "class='azul'" %> >
          <td align="center">
              <% using (Html.BeginForm("Apagar", "Cadastro", FormMethod.Post)) { %>
		              <%: Html.Hidden("SEQ_CADASTRO", cadastro.SEQ_CADASTRO) %>
		              <input type="image" src="../../Content/Imagens/deleteIcon.png" />
		          <% } %></td>
          <td><%: Html.ActionLink(cadastro.DSC_NOME, "Editar", new { id = cadastro.SEQ_CADASTRO }) %></td>
          <td><%: String.Format("{0:dd/MM/yyyy}", cadastro.DAT_CADASTRO) %></td>
          <td><%: String.Format("{0:dd/MM/yyyy}", cadastro.DAT_CADASTRO) %></td>
          <td><%: cadastro.NUM_TELEFONE_CELULAR %></td>
          <td><%: cadastro.ACADEMIA.NOM_ACADEMIA %></td>
          <td><%: Model.nomearGraduacao(cadastro.SEQ_CADASTRO) %></td>
       </tr>
    
    <% } %>
      </tbody>

    </table>

    <p>
        <%: Html.ActionLink("Novo", "Criar") %>
    </p>

</asp:Content>

